<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>职业意向选择</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/myDevelop.css" />
</head>
<body>
  <div id="header">
      <div id="back"></div>
      <h3>职业意向选择</h3>
  </div>
  <div id="all">
    <div class="jobList">
      <div class="title">请选择</div>
    </div>
  </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
apiready=function(){
  var flag=$api.getStorage('flag');
  var aid=$api.getStorage('aid');
  var jwt=$api.getStorage('jwt');
  //获取可以选择的职业意向列表
  api.ajax({
    url: 'http://47.104.170.122/v1/portal/career/student/careers?token='+jwt,
    method: 'GET',
    headers: {
      "Access-Control-Allow-Origin": "*",
      "Access-Control-Allow-Headers": "Authorization",
      "Content-Type" : 'application/json; charset=utf-8'
    }
  }, function(ret, err) {
    if(ret.code==0){
      $.each(ret.data,function(i,val){
        $(".jobList").append('<div class="item" id="'+ret.data[i].id+'">'+ret.data[i].name+'</div>')
      })
    }
  });
  $(".jobList").on("click",".item",function(){
      var that=$(this);
      api.confirm({
      title: '是否确认选择'+that.html()+'作为自己的职业意向',
      buttons: ['确定', '取消']
      }, function(ret, err) {
          var index = ret.buttonIndex;
          var id=that.attr("id");
          var JobName=that.html();
          if(index==1){
            api.ajax({
              url: 'http://47.104.170.122/v1/portal/career/student/selectCareer/?id='+id+'&token='+jwt,
              method: 'POST',
              headers: {
                "Access-Control-Allow-Origin": "*",
                "Access-Control-Allow-Headers": "Authorization",
                "Content-Type" : 'application/json; charset=utf-8'
              }
            }, function(ret, err) {
              if(ret.code==0){
                alert("选择成功！");
                api.openWin({
                    name: 'myJob',
                    url: 'myJob.html',
                    scrollEnabled:false,
                    pageParam: {
                        id:id,
                        JobName:JobName
                    }
                });
              }
            });
          }
      });
  });
}
//jquery
$(function(){
  back();
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
